return g_strdup (gtk_font_button_get_font_name (font_button));
}
-static gboolean
+static void
gtk_font_button_font_chooser_set_font (GtkFontChooser *chooser,
const gchar *fontname)
{
GtkFontButton *font_button = GTK_FONT_BUTTON (chooser);
- return gtk_font_button_set_font_name (font_button, fontname);
+ gtk_font_button_set_font_name (font_button, fontname);
}
static PangoFontFamily *
gtk_font_button_set_font_name (GtkFontButton *font_button,
const gchar *fontname)
{
- gboolean result;
gchar *old_fontname;
g_return_val_if_fail (GTK_IS_FONT_BUTTON (font_button), FALSE);
gtk_font_button_update_font_info (font_button);
if (font_button->priv->font_dialog)
- result = gtk_font_chooser_set_font (GTK_FONT_CHOOSER (font_button->priv->font_dialog),
- font_button->priv->fontname);
- else
- result = FALSE;
+ gtk_font_chooser_set_font (GTK_FONT_CHOOSER (font_button->priv->font_dialog),
+ font_button->priv->fontname);
g_object_notify (G_OBJECT (font_button), "font");
g_object_notify (G_OBJECT (font_button), "font-name");
- return result;
+ return TRUE;
}
static void
static guint chooser_signals[LAST_SIGNAL];
-#define DEFAULT_FONT_NAME "Sans 10"
-#define MAX_FONT_SIZE 999
-
typedef GtkFontChooserIface GtkFontChooserInterface;
G_DEFINE_INTERFACE (GtkFontChooser, gtk_font_chooser, G_TYPE_OBJECT);
g_param_spec_string ("font",
P_("Font"),
P_("The string that represents this font"),
- DEFAULT_FONT_NAME,
+ GTK_FONT_CHOOSER_DEFAULT_FONT_NAME,
GTK_PARAM_READWRITE));
g_object_interface_install_property
*
* Sets the currently-selected font.
*
- * Return value: %TRUE if the font could be set successfully; %FALSE
- * if no such font exists or if the @fontchooser doesn't belong
- * to a particular screen yet.
- *
* Since: 3.2
*/
-gboolean
+void
gtk_font_chooser_set_font (GtkFontChooser *fontchooser,
const gchar *fontname)
{
- g_return_val_if_fail (GTK_IS_FONT_CHOOSER (fontchooser), FALSE);
- g_return_val_if_fail (fontname != NULL, FALSE);
+ g_return_if_fail (GTK_IS_FONT_CHOOSER (fontchooser));
+ g_return_if_fail (fontname != NULL);
- return GTK_FONT_CHOOSER_GET_IFACE (fontchooser)->set_font (fontchooser,
- fontname);
+ GTK_FONT_CHOOSER_GET_IFACE (fontchooser)->set_font (fontchooser,
+ fontname);
}
/**
/* Methods */
gchar * (* get_font) (GtkFontChooser *chooser);
- gboolean (* set_font) (GtkFontChooser *chooser,
+ void (* set_font) (GtkFontChooser *chooser,
const gchar *fontname);
PangoFontFamily * (* get_font_family) (GtkFontChooser *chooser);
PangoFontFace * (* get_font_face) (GtkFontChooser *chooser);
gint gtk_font_chooser_get_size (GtkFontChooser *fontchooser);
gchar* gtk_font_chooser_get_font (GtkFontChooser *fontchooser);
-gboolean gtk_font_chooser_set_font (GtkFontChooser *fontchooser,
+void gtk_font_chooser_set_font (GtkFontChooser *fontchooser,
const gchar *font_name);
gchar* gtk_font_chooser_get_preview_text (GtkFontChooser *fontchooser);
void gtk_font_chooser_set_preview_text (GtkFontChooser *fontchooser,
#include "gtkfontchooser.h"
+#define GTK_FONT_CHOOSER_DEFAULT_FONT_NAME "Sans 10"
+
G_BEGIN_DECLS
void _gtk_font_chooser_font_activated (GtkFontChooser *chooser,
return gtk_font_chooser_get_font (get_delegate (chooser));
}
-static gboolean
+static void
delegate_set_font (GtkFontChooser *chooser,
const gchar *fontname)
{
- return gtk_font_chooser_set_font (get_delegate (chooser), fontname);
+ gtk_font_chooser_set_font (get_delegate (chooser), fontname);
}
static PangoFontFamily *
static void gtk_font_chooser_widget_bootstrap_fontlist (GtkFontChooserWidget *fontchooser);
-static gboolean gtk_font_chooser_widget_select_font_name (GtkFontChooserWidget *fontchooser);
+static void gtk_font_chooser_widget_select_font_name (GtkFontChooserWidget *fontchooser);
static gchar *gtk_font_chooser_widget_get_font (GtkFontChooser *chooser);
-static gboolean gtk_font_chooser_widget_set_font (GtkFontChooser *chooser,
+static void gtk_font_chooser_widget_set_font (GtkFontChooser *chooser,
const gchar *fontname);
static const gchar *gtk_font_chooser_widget_get_preview_text (GtkFontChooserWidget *fontchooser);
GTK_TREE_VIEW (priv->family_face_list),
priv->model);
- if (priv->fontname)
- gtk_font_chooser_widget_select_font_name (fontchooser);
+ gtk_font_chooser_widget_select_font_name (fontchooser);
}
static void
PangoFontDescription *desc;
if (!fontchooser->priv->face)
- return NULL;
+ return g_strdup (GTK_FONT_CHOOSER_DEFAULT_FONT_NAME);
desc = pango_font_face_describe (fontchooser->priv->face);
font_desc_name = pango_font_description_to_string (desc);
return font_name;
}
-static gboolean
+static void
gtk_font_chooser_widget_set_font (GtkFontChooser *chooser,
const gchar *fontname)
{
GtkFontChooserWidget *fontchooser = GTK_FONT_CHOOSER_WIDGET (chooser);
GtkFontChooserWidgetPrivate *priv = fontchooser->priv;
- gboolean found = FALSE;
if (priv->fontname)
g_free (priv->fontname);
priv->fontname = g_strdup (fontname);
if (gtk_widget_has_screen (GTK_WIDGET (fontchooser)))
- found = gtk_font_chooser_widget_select_font_name (fontchooser);
+ gtk_font_chooser_widget_select_font_name (fontchooser);
g_object_notify (G_OBJECT (fontchooser), "font");
-
- return found;
}
-static gboolean
+static void
gtk_font_chooser_widget_select_font_name (GtkFontChooserWidget *fontchooser)
{
GtkFontChooserWidgetPrivate *priv = fontchooser->priv;
PangoFontDescription *desc;
gboolean found = FALSE;
- desc = pango_font_description_from_string (priv->fontname);
+ if (priv->fontname)
+ desc = pango_font_description_from_string (priv->fontname);
+ else
+ desc = pango_font_description_from_string (GTK_FONT_CHOOSER_DEFAULT_FONT_NAME);
+
family_name = (gchar*)pango_font_description_get_family (desc);
g_free (priv->fontname);
if (!family_name)
{
pango_font_description_free (desc);
- return FALSE;
+ return;
}
/* We make sure the filter is clear */
}
pango_font_description_free (desc);
-
- return found;
}
static const gchar*